#ifndef xpack_lang_cxx_pad_bends
#define xpack_lang_cxx_pad_bends
#pragma push_macro("xuser")
#undef  xuser
#define xuser mixc::lang_cxx::inc
#include"define/base_type.hpp"
#include"lang/cxx.hpp"
#include"macro/xunlikely.hpp"
#include"memop/copy.hpp"
#include"memop/fill.hpp"
#pragma pop_macro("xuser")

namespace mixc::lang_cxx{
    template<class item_t>
    template<class xalloc_t, class ret_t, class>
    inline ret_t cxx<item_t>::pad_bends(uxx left_count, uxx right_count, item_cref_t pad, xalloc_t const & alloc) const {
        return xthe.pad_bends(left_count, right_count, pad, pad, alloc);
    }

    template<class item_t>
    template<class xalloc_t, class ret_t, class>
    inline ret_t cxx<item_t>::pad_bends(
        uxx                     left_count, 
        uxx                     right_count,
        item_cref_t             pad_left, 
        item_cref_t             pad_right, 
        xalloc_t        const & alloc
    ) const {
        auto result         = the_t{};
        auto allocx         = the_t::helper::stream_helper(alloc, xmodify(result.m_ptr), xmodify(result.m_length));
        auto length         = left_count + right_count + xthe->length;
        auto stream         = allocx(length);

        if (stream != nullptr){
            stream.output(pad_left, left_count);
            stream.output(m_ptr, m_length);
            stream.output(pad_right, right_count);
        }

        if constexpr (inc::is_same<ret_t, the_t>){
            return result;
        }
    }
}

#endif
